\bfi % ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
a)\raisebox{-0.4\textwidth}{\ig{height=0.45\textwidth}{extconv.eps}}
b)\raisebox{-0.4\textwidth}{\ig{height=0.45\textwidth}{extgeom_filtered.eps}}
\ca{a) Convergence of exterior Helmholtz BVP with MFS basis,
b) Domain boundary and MFS charge curve geometry, and
(real part of) the solution field outside the domain.}{f:ext}
\efi

% ----------------------------------------------------------------------------
\section{Helmholtz equation, exterior and multiply connected domains}
\label{s:ext}

Changing from the Laplace to Helmholtz equation is as simple
as setting {\tt d.k} to a positive value.
We start a fresh example: an exterior Helmholtz BVP
with Neumann boundary data, and the Sommerfeld radiation
condition \cite{coltonkress}. This has a unique solution.

The simplest unbounded domain is $\mathbb{R}^2$, which is created with
\co{d = domain([], []);}
One may check that its area {\tt d.area} is $\infty$.
Exterior domains can be created by excluding from $\mathbb{R}^2$
the interior of
a closed segment, for instance the trefoil segment introduced above,
\begin{verbatim}
tref = segment.radialfunc(100, {@(q) 1 + 0.3*cos(3*q), @(q) -0.9*sin(3*q)});
d = domain([], [], tref, -1);   % overwrites previous d
\end{verbatim}
Note the choice $-1$ for the direction argument, which states that
the domain lies on the `nonstandard' side of the segment, i.e.\
to the right side as the segment is traversed in its natural sense,
with the segment normals pointing {\em into} the exterior domain.
As before, we set up Dirichlet boundary data corresponding to a known
radiative solution (a point source lying in the segment interior),
\begin{verbatim}
d.k = 10; f = @(z) besselh(0,d.k * abs(z-0.3-0.2i));
tref.setbc(1, 'D', [], @(t) f(tref.Z(t))); 
\end{verbatim}
A convenient basis set for radiative solutions is a set of fundamental
solutions (`MFS basis') with origins $\by_j$
lying on a closed curve interior to the segment.
The formula for the $j$th basis function at location
$\bx\in\mathbb{R}^2\setminus \by_j$
is $\Phi(|\bx-\by_j|)$, where
the fundamental solution for the Helmholtz equation at wavenumber $k$ is
$\Phi(\bx) = \frac{i}{4}H_0^{(1)} (k|\bx|)$.
We set this up and plot convergence of boundary error norm,
\begin{verbatim}
opts.tau = 0.06; d.addmfsbasis(tref, [], opts);
p = bvp(d);
for N=5:5:80,
  p.updateN(N); p.solvecoeffs; r(N) = p.bcresidualnorm;
end
figure; semilogy(r, '+-'); xlabel('N'); ylabel('bdry err norm');
\end{verbatim}
This gives the convergence plot Fig.~\ref{f:ext}a, and
executing {\tt d.plot; p.showbasesgeom; p.showsolution;} gives
Fig.~\ref{f:ext}b. Notice that the MFS charges lie some distance interior
to the curve---this is controlled by the {\tt opts.tau} parameter which
makes use of the fact that the segment is specified as an analytic function
and hence generates a new curve when the parameter $t$ is displaced
by $\tau$ in the imaginary direction.%
  \footnote{A general rule is that for good spectral convergence
    the MFS curve should be
    as far as possible from the solution domain boundary, while still
    `shielding' this boundary from singularities in the analytic continuation
    of the solution field. The user will have to adjust this parameter,
    although it should not depend on $k$. See~\cite{mfs}.}
Plotting pointwise error with
\co{opts.comparefunc = f; figure; p.showsolution(opts);}
shows that is it around $10^{-13}$.


\bfi % ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
a)\raisebox{-0.4\textwidth}{\ig{height=0.45\textwidth}{twoholes.eps}}
b)\raisebox{-0.4\textwidth}{\ig{height=0.45\textwidth}{tri.eps}}
\ca{a) A multiply-connected domain. b) A polygonal domain.}{f:doms}
\efi

A non-simply connected domain may be built by specifying excluded
regions from a simply connected bounded domain. For example,
to remove from an interior trefoil a circular `hole',
\begin{verbatim}
   tref.disconnect;  % clears any domains from segment
   c = segment([], [0.5 0.4 0 2*pi]); % new circular segment
   d = domain(tref, 1, c, -1);
\end{verbatim}
Note that segment {\tt tref} had previously
been `linked' to the old domain {\tt d}
at the start of this section, hence the need to `disconnect' it
(or create a fresh segment) before
building new domains from it. 
If the direction signs $+1$ and $-1$ are not correct as above, an
error is reported (check this!)
We may exclude two regions as follows, where the new region is a smaller copy
of the trefoil,
\begin{verbatim}
   tref.disconnect; c.disconnect;
   smtref = tref.scale(0.3);    % create new rescaled tref copy
   smtref.translate(-0.3+0.4i); % move the segment smtref
   d = domain(tref, 1, {c smtref}, {-1 -1});
\end{verbatim}
Typing {\tt d.plot} gives Fig.~\ref{f:doms}a. Notice that
the domain's boundary is the union of three segments. They are labeled
1, 2, and 3, showing the order in which segment handles
are stored internally in the domain object {\tt d.seg}.
The convention for plotting domains is that the normals
are those of the domain, rather than the normal intrinsic to each segment.
The figure shows all normals pointing away from the domain, as it should.
Similarly, the arrow directions are modified by the signs $(1,-1,-1)$ that
were passed in, so that, following the arrows the domain always lies to
the {\em left}. (The black semicircles will be explained in the next section.)

More complicated domains similar to the above will be demonstrated later in
Secs.~\ref{s:qpsc} and \ref{s:exa}.
%[MAYBE add mfsbasis example here with three src curves one for each segment?]

\vspace{10ex}



%%% Local Variables: 
%%% mode: latex
%%% TeX-master: "tutorial"
%%% End: 
